import request, { IResult } from '../utils/request-new'

export interface IUser{
  avatar?: string,
  city?: string
  hospital?: string
  id: number
  mobile?: string
  name?: string
  position?: string
  province?: string
}

// 微信登录
export const postWxLogin = (data: {
  code: string,
  mobile: string
}) => {
  return request<IRequestData>({
    url: `/login/weixin`,
    method: "POST",
    data
  })
}

// 获取手机号码
export const getPhoneNumber = (data: {
  code: string
}) => {
  return request({
    url: `/login/getMobile/${data.code}`,
    method: "GET"
  })
}

// 获取用户信息
export const getUserInfo = (): Promise<IResult<IUser>> => {
  return request<IUser>({
    url: `/user/getInfo`,
    method: "GET"
  })
}

// 用户信息
export const editUserInfo = (data: IUser) => {
  return request({
    url: `/user/edit`,
    method: "PUT",
    data
  })
}

